<template>
    <el-form-item label="">
        <el-form-item label="" :prop="`adgroup.delivery.${dataForm.delivery_index}.deep_bid_type`">
            <el-checkbox v-model="dataForm.adgroup.delivery[dataForm.delivery_index].deep_bid_type" true-label="VO_MIN_ROAS" false-label="VO_HIGHEST_VALUE" @change="changeDeep">设置广告花费回报（ROAS）下限值</el-checkbox>
        </el-form-item>
        <el-form-item label="" :prop="`adgroup.delivery.${dataForm.delivery_index}.roas_bid`" :rules="createRules.checkPrice" style="margin-top:10px" v-if="dataForm.adgroup.delivery[dataForm.delivery_index].deep_bid_type=='VO_MIN_ROAS'">
            <el-input v-model="dataForm.adgroup.delivery[dataForm.delivery_index].roas_bid" @change="sessionSave" placeholder="请输入" style="width:120px">
            </el-input>
        </el-form-item>
    </el-form-item>
</template>

<script>
export default {
    props: ["dataForm"],
    components: {},
    name: "",
    data() {
        var checkPrice = (rule, value, callback) => {
            let reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
            let price = Number(value)
            if (!reg.test(price)) {
                return callback(new Error("请输入正确的数值"));
            }else {
                callback();
            }
        };
        return {
            createRules:{
                checkPrice: [
                    {required: true,message: "请输入",trigger: ["blur", "change"],},
                    { validator: checkPrice, trigger: ["blur", "change"] },
                ],
            }
        };
    },
    created() {},
    methods: {
        sessionSave() {
            this.$emit("sessionSave");
        },

        changeDeep(){
            this.dataForm.adgroup.delivery[this.dataForm.delivery_index].roas_bid = ""
        },
    },
};
</script>


<style scoped>
</style>

